package com.ktgj.flight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.flight.domain.FlightDeliverCustomer;
import com.ktgj.flight.service.IFlightDeliverCustomerService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 会员邮寄列Controller
 * 
 * @author ruoyi
 * @date 2021-10-26
 */
@ControllerAdvice
@RestController
@RequestMapping("/customer")
public class FlightDeliverCustomerController extends BaseController
{
    @Autowired
    private IFlightDeliverCustomerService flightDeliverCustomerService;

    /**
     * 查询会员邮寄列列表
     */
    @PreAuthorize(hasPermi = "flight:customer:list")
    @GetMapping("/list")
    public TableDataInfo list(FlightDeliverCustomer flightDeliverCustomer)
    {
        startPage();
        List<FlightDeliverCustomer> list = flightDeliverCustomerService.selectFlightDeliverCustomerList(flightDeliverCustomer);
        return getDataTable(list);
    }

    /**
     * 导出会员邮寄列列表
     */
    @PreAuthorize(hasPermi = "flight:customer:export")
    @Log(title = "会员邮寄列", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FlightDeliverCustomer flightDeliverCustomer) throws IOException
    {
        List<FlightDeliverCustomer> list = flightDeliverCustomerService.selectFlightDeliverCustomerList(flightDeliverCustomer);
        ExcelUtil<FlightDeliverCustomer> util = new ExcelUtil<FlightDeliverCustomer>(FlightDeliverCustomer.class);
        util.exportExcel(response, list, "会员邮寄列数据");
    }

    /**
     * 获取会员邮寄列详细信息
     */
    @PreAuthorize(hasPermi = "flight:customer:query")
    @GetMapping(value = "/{deliverid}")
    public AjaxResult getInfo(@PathVariable("deliverid") Long deliverid)
    {
        return AjaxResult.success(flightDeliverCustomerService.selectFlightDeliverCustomerById(deliverid));
    }

    /**
     * 新增会员邮寄列
     */
    @PreAuthorize(hasPermi = "flight:customer:add")
    @Log(title = "会员邮寄列", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlightDeliverCustomer flightDeliverCustomer)
    {
        return toAjax(flightDeliverCustomerService.insertFlightDeliverCustomer(flightDeliverCustomer));
    }

    /**
     * 修改会员邮寄列
     */
    @PreAuthorize(hasPermi = "flight:customer:edit")
    @Log(title = "会员邮寄列", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlightDeliverCustomer flightDeliverCustomer)
    {
        return toAjax(flightDeliverCustomerService.updateFlightDeliverCustomer(flightDeliverCustomer));
    }

    /**
     * 删除会员邮寄列
     */
    @PreAuthorize(hasPermi = "flight:customer:remove")
    @Log(title = "会员邮寄列", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deliverids}")
    public AjaxResult remove(@PathVariable Long[] deliverids)
    {
        return toAjax(flightDeliverCustomerService.deleteFlightDeliverCustomerByIds(deliverids));
    }
}
